<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>试题管理页</title>
    <link rel="shortcut icon" href="/favicon.ico">

    <!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link href="/public/admin/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/public/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/public/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/public/admin/css/animate.css" rel="stylesheet">
    <link href="/public/admin/css/style.css?v=4.0.0" rel="stylesheet">
    <link href="/public/admin/css/ourstyle.css?v=4.0.0" rel="stylesheet">
    <link href="/public/admin/js/plugins/layer/skin/layer.css" rel="stylesheet">
    <style>
        /*#tab-1 .form-group{
            display:none;
        }*/
    </style>
    <!-- 全局js -->
    <script src="/public/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/public/admin/js/bootstrap.min.js?v=3.3.5"></script>
    <!-- 自定义js -->
    <script src="/public/admin/js/content.js?v=1.0.0"></script>
    <script src="/public/admin/js/plugins/layer/layer.min.js"></script>
    <script src="/public/admin/plugins/laydate/laydate.js"></script>
    <script src="/public/admin/js/article.js"></script>
    <script src="/public/admin/js/common.js"></script>
    <!-- CKeditor -->
    <script src="/public/admin/plugins/ckeditor/ckeditor.js"></script>
    <script type="text/javascript" src="/public/admin/plugins/ckfinder/ckfinder.js"></script>
    <!-- iCheck -->
    <script src="/public/admin/js/plugins/iCheck/icheck.min.js"></script>
</head>

<body class="fixed-sidebar full-height-layout gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title" style="display:none">
                    <h5>试题内容</h5>
                </div>
                <div class="ibox-content">
                    <ul class="nav nav-tabs">
                        <li class="active"><a data-toggle="tab" href="#tab-1"> 基本信息</a></li>
                    </ul>
                    <br/>
                    <div class="row">
                        <form action="" method="post" id="articleFrom" class="form-horizontal">
                            <div class="tab-content">
                                <div id="tab-1" class="tab-pane active">
                                    <div class="form-group" style="display:none">
                                        <label class="col-sm-2 control-label">科目：</label>
                                        <div class="col-sm-8">
                                            <select class="form-control" name="subjectid">
                                                {foreach name="subjectList" item="v"}
                                                <option value="{$v.subjectid}" {eq name="v.subjectid" value="$one['subjectid']"}selected="selected"{/eq}>{$v.subject_name}</option>
                                                {/foreach}
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group" style="display:none">
                                        <label class="col-sm-2 control-label">题型：</label>
                                        <div class="col-sm-8">
                                            <select class="form-control" name="qtypeid">
                                                {foreach name="qtypeList" item="v"}
                                                <option value="{$v.qtypeid}" {eq name="v.qtypeid" value="$one['qtypeid']"}selected="selected"{/eq}>{$v.qtype_name}</option>
                                                {/foreach}
                                            </select>
                                        </div>
                                    </div>
                                    {php}
                                    $subject = Db::name('subject')->find($one['subjectid']);
                                    $qtype = Db::name('qtype')->find($one['qtypeid']);
                                    {/php}
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">科目：</label>
                                        <div class="col-sm-8">
                                            <input class="configInput form-control" name="" minlength="2" type="text" value="{$subject.subject_name}" required="" aria-required="true" placeholder="" disabled>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">周次：</label>
                                        <div class="col-sm-8">
                                            <select class="form-control" name="weekid">
                                                <option value="">不限</option>
                                                {foreach name="weekList" item="v"}
                                                <option value="{$v.weekid}" {eq name="v.weekid" value="$one['weekid']"}selected="selected"{/eq}>{$v.week_name}</option>
                                                {/foreach}
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">题型：</label>
                                        <div class="col-sm-8">
                                            <input class="configInput form-control" name="" minlength="2" type="text" value="{$qtype.qtype_name}" required="" aria-required="true" placeholder="" disabled>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">题目：</label>
                                        <div class="col-sm-8">
                                            <textarea id="question" name="question" rows="2" cols="20">{$one.question|htmlspecialchars_decode}</textarea>
                                        </div>
                                    </div>
                                    <div id="area_select" style="display:none">
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">选项A：</label>
                                            <div class="col-sm-8">
                                                <input class="configInput form-control" name="question_select[]" minlength="2" type="text" value="{$one.questionSelect.A}" required="" aria-required="true" placeholder="选项A的内容">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">选项B：</label>
                                            <div class="col-sm-8">
                                                <input class="configInput form-control" name="question_select[]" minlength="2" type="text" value="{$one.questionSelect.B}" required="" aria-required="true" placeholder="选项B的内容">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">选项C：</label>
                                            <div class="col-sm-8">
                                                <input class="configInput form-control" name="question_select[]" minlength="2" type="text" value="{$one.questionSelect.C}" required="" aria-required="true" placeholder="选项C的内容">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">选项D：</label>
                                            <div class="col-sm-8">
                                                <input class="configInput form-control" name="question_select[]" minlength="2" type="text" value="{$one.questionSelect.D}" required="" aria-required="true" placeholder="选项D的内容，如果没有，请不要填写">
                                            </div>
                                        </div>
                                        <div class="form-group" style="display:none">
                                            <label class="col-sm-2 control-label">选项E：</label>
                                            <div class="col-sm-8">
                                                <input class="configInput form-control" name="question_select[]" minlength="2" type="text" value="{$one.questionSelect.E}" required="" aria-required="true" placeholder="选项E的内容，如果没有，请不要填写">
                                            </div>
                                        </div>
                                        <div class="form-group" style="display:none">
                                            <label class="col-sm-2 control-label">选项F：</label>
                                            <div class="col-sm-8">
                                                <input class="configInput form-control" name="question_select[]" minlength="2" type="text" value="{$one.questionSelect.F}" required="" aria-required="true" placeholder="选项F的内容，如果没有，请不要填写">
                                            </div>
                                        </div>
                                        <div class="form-group" style="display:none">
                                            <label class="col-sm-2 control-label">选项G：</label>
                                            <div class="col-sm-8">
                                                <input class="configInput form-control" name="question_select[]" minlength="2" type="text" value="{$one.questionSelect.G}" required="" aria-required="true" placeholder="选项G的内容，如果没有，请不要填写">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group" id="area_answer_radio" style="display:none">
                                        <label class="col-sm-2 control-label">正确答案：</label>
                                        <div class="col-sm-8">
                                            <label class="checkbox-inline i-checks">
                                                <input type="radio" name="question_answer_radio" value="A" {eq name="one.question_answer_radio" value="A"}checked="checked"{/eq}>A</label>
                                            <label class="checkbox-inline i-checks">
                                                <input type="radio" name="question_answer_radio" value="B" {eq name="one.question_answer_radio" value="B"}checked="checked"{/eq}>B</label>
                                            <label class="checkbox-inline i-checks">
                                                <input type="radio" name="question_answer_radio" value="C" {eq name="one.question_answer_radio" value="C"}checked="checked"{/eq}>C</label>
                                            <label class="checkbox-inline i-checks">
                                                <input type="radio" name="question_answer_radio" value="D" {eq name="one.question_answer_radio" value="D"}checked="checked"{/eq}>D</label>
                                            <label class="checkbox-inline i-checks" style="display:none"> style="display:none"
                                                <input type="radio" name="question_answer_radio" value="E" {eq name="one.question_answer_radio" value="E"}checked="checked"{/eq}>E</label>
                                            <label class="checkbox-inline i-checks" style="display:none">
                                                <input type="radio" name="question_answer_radio" value="F" {eq name="one.question_answer_radio" value="F"}checked="checked"{/eq}>F</label>
                                            <label class="checkbox-inline i-checks" style="display:none">
                                                <input type="radio" name="question_answer_radio" value="G" {eq name="one.question_answer_radio" value="G"}checked="checked"{/eq}>G</label>
                                        </div>
                                    </div>
                                    <div class="form-group" id="area_answer_checkbox" style="display:none">
                                        <label class="col-sm-2 control-label">正确答案：</label>
                                        <div class="col-sm-8">
                                            <label class="checkbox-inline i-checks">
                                                <input type="checkbox" name="question_answer_checkbox[]" value="A" {if in_array('A',$one['question_answer_checked'])}checked="checked"{/if}>A</label>
                                            <label class="checkbox-inline i-checks">
                                                <input type="checkbox" name="question_answer_checkbox[]" value="B" {if in_array('B',$one['question_answer_checked'])}checked="checked"{/if}>B</label>
                                            <label class="checkbox-inline i-checks">
                                                <input type="checkbox" name="question_answer_checkbox[]" value="C" {if in_array('C',$one['question_answer_checked'])}checked="checked"{/if}>C</label>
                                            <label class="checkbox-inline i-checks">
                                                <input type="checkbox" name="question_answer_checkbox[]" value="D" {if in_array('D',$one['question_answer_checked'])}checked="checked"{/if}>D</label>
                                            <label class="checkbox-inline i-checks" style="display:none">
                                                <input type="checkbox" name="question_answer_checkbox[]" value="E" {if in_array('E',$one['question_answer_checked'])}checked="checked"{/if}>E</label>
                                            <label class="checkbox-inline i-checks" style="display:none">
                                                <input type="checkbox" name="question_answer_checkbox[]" value="F" {if in_array('F',$one['question_answer_checked'])}checked="checked"{/if}>F</label>
                                            <label class="checkbox-inline i-checks" style="display:none">
                                                <input type="checkbox" name="question_answer_checkbox[]" value="G" {if in_array('G',$one['question_answer_checked'])}checked="checked"{/if}>G</label>
                                        </div>
                                    </div>
                                    <div class="form-group" id="area_answer_judge" style="display:none">
                                        <label class="col-sm-2 control-label">正确答案：</label>
                                        <div class="col-sm-8">
                                            <label class="checkbox-inline i-checks">
                                                <input type="radio" name="question_answer_judge" value="A" {eq name="one.question_answer_judge" value="A"}checked="checked"{/eq}>对</label>
                                            <label class="checkbox-inline i-checks">
                                                <input type="radio" name="question_answer_judge" value="B" {eq name="one.question_answer_judge" value="B"}checked="checked"{/eq}>错</label>
                                            <label class="checkbox-inline i-checks">
                                        </div>
                                    </div>
                                    <div class="form-group" id="area_answer_fill" style="display:none">
                                        <label class="col-sm-2 control-label">参考答案：</label>
                                        <div class="col-sm-8">
                                            <textarea id="question_answer_fill" name="question_answer_fill" rows="2" cols="20">{$one.question_answer_fill|htmlspecialchars_decode}</textarea>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">答案解析：</label>
                                        <div class="col-sm-8">
                                            <textarea id="question_analyse" name="question_analyse" rows="2" cols="20">{$one.question_analyse|htmlspecialchars_decode}</textarea>
                                        </div>
                                    </div>
                                    <div class="form-group" data-name="question_order" style="display:none">
                                        <label class="col-sm-2 control-label">序号：</label>
                                        <div class="col-sm-8">
                                            <input class="configInput form-control" name="question_order" type="number" class="configInput" value="{one.question_order}">
                                        </div>
                                    </div>
                                    <div class="form-group" data-name="add_time" style="display:none">
                                        <label class="col-sm-2 control-label">添加时间：</label>
                                        <div class="col-sm-8">
                                            <input class="configInput form-control" name="add_time" type="text" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" required="" aria-required="true" value="{$one.add_time|date="Y-m-d H:i:s"}">
                                        </div>
                                    </div>


                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <input type="hidden" name="questionid" value="{$one.questionid}" />
                                    <input type="hidden" name="admin_id" value="{$one.admin_id}" />
                                    <input type="hidden" name="user_name" value="{$one.user_name}" />
                                    <button class="btn btn-primary" onclick="ajax_submit_form('articleFrom','{:url('Question/questionEdit')}')" type="button">保存</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
//        editorReplace('content');
        CKEDITOR.replace( 'question', {
            language : 'zh-cn',
            toolbar : [
                ['Source'],
                { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','-','RemoveFormat' ] },
                { name: 'links', items : [ 'Link','Unlink' ] },
                { name: 'insert', items : [ 'Image'] },
                { name: 'styles', items : ['Format','Font','FontSize' ] },
            ],
            resize_enabled : true,  //是否可以自行拖拽编辑器大小
            height : '100px',  //编辑器高度
            // width : '1000px',  //编辑器宽度
        });
        CKEDITOR.replace( 'question_answer_fill', {
            language : 'zh-cn',
            toolbar : [
                ['Source'],
                { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','-','RemoveFormat' ] },
                { name: 'links', items : [ 'Link','Unlink' ] },
                { name: 'insert', items : [ 'Image'] },
                { name: 'styles', items : ['Format','Font','FontSize' ] },
            ],
            resize_enabled : true,  //是否可以自行拖拽编辑器大小
            height : '100px',  //编辑器高度
            // width : '1000px',  //编辑器宽度
        });
        CKEDITOR.replace( 'question_analyse', {
            language : 'zh-cn',
            toolbar : [
                ['Source'],
                { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','-','RemoveFormat' ] },
                { name: 'links', items : [ 'Link','Unlink' ] },
                { name: 'insert', items : [ 'Image'] },
                { name: 'styles', items : ['Format','Font','FontSize' ] },
            ],
            resize_enabled : true,  //是否可以自行拖拽编辑器大小
            height : '100px',  //编辑器高度
            // width : '1000px',  //编辑器宽度
        });
    });
</script>
<script>
    $("select[name='qtypeid']").change(function(){
        $('#area_select').hide();
        $('#area_answer_radio').hide();
        $('#area_answer_checkbox').hide();
        $('#area_answer_judge').hide();
        $('#area_answer_fill').hide();
        var qtypeid = $(this).val();
        //1单选,2多选，3判断，4填空
        if(qtypeid == 1){
            $('#area_select').show();
            $('#area_answer_radio').show();
        }else if(qtypeid == 2){
            $('#area_select').show();
            $('#area_answer_checkbox').show();
        }else if(qtypeid == 3){
            $('#area_answer_judge').show();
        }else if(qtypeid==4){
            $('#area_answer_fill').show();
        }
    })
    $("select[name='qtypeid']").trigger('change');


    CKEDITOR.on('instanceReady', function (ev) {
        var editor = ev.editor,
                dataProcessor = editor.dataProcessor,
                htmlFilter = dataProcessor && dataProcessor.htmlFilter;
        dataProcessor.writer.selfClosingEnd = '>';
        // Make output formatting behave similar to FCKeditor
        var dtd = CKEDITOR.dtd;
        for (var e in CKEDITOR.tools.extend({}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent)) {
            dataProcessor.writer.setRules(e,
                    {
                        indent: true,
                        breakBeforeOpen: true,
                        breakAfterOpen: false,
                        breakBeforeClose: !dtd[e]['#'],
                        breakAfterClose: true
                    });
        }
        // Output properties as attributes, not styles.
        htmlFilter.addRules(
                {
                    elements:
                    {
                        $: function (element) {
                            // Output dimensions of images as width and height
                            if (element.name == 'img') {
                                var style = element.attributes.style;
                                // delete element.attributes.style;//删除宽高
                            }

                            if (!element.attributes.style)
                            // delete element.attributes.style;//删除宽高
                                return element;
                        }
                    },
                    attributes:
                    {
                        style: function (value, element) {
                            // Return #RGB for background and border colors
                            //return convertRGBToHex(value);
                        }
                    }
                });
    });
</script>
</body>
</html>
